Class pyglet.image.Animation

Sequence of images with timing information.

If no frames of the animation have a duration of None, the animation loops continuously; otherwise the animation stops at the first frame with duration of None.

Methods

  __init__(self, frames)
Create an animation directly from a list of frames.
  add_to_texture_bin(self, bin)
Add the images of the animation to a TextureBin.
Animation get_transform(self, flip_x=False, flip_y=False, rotate=0)
Create a copy of this animation applying a simple transformation.
float get_duration(self)
Get the total duration of the animation in seconds.
int get_max_width(self)
Get the maximum image frame width.
int get_max_height(self)
Get the maximum image frame height.
Animation from_image_sequence(cls, sequence, period, loop=True)
Create an animation from a list of images and a constant framerate.

Instance Variables

list of AnimationFrame frames
The frames that make up the animation.

Method Details

__init__

(Constructor) __init__(self, frames)
Create an animation directly from a list of frames.
Parameters:
frames : list of AnimationFrame
The frames that make up the animation.

add_to_texture_bin

add_to_texture_bin(self, bin)

Add the images of the animation to a TextureBin.

The animation frames are modified in-place to refer to the texture bin regions.

Parameters:
bin : TextureBin
Texture bin to upload animation frames into.

get_transform

get_transform(self, flip_x=False, flip_y=False, rotate=0)

Create a copy of this animation applying a simple transformation.

The transformation is applied around the image's anchor point of each frame. The texture data is shared between the original animation and the transformed animation.

Parameters:
flip_x : bool
If True, the returned animation will be flipped horizontally.
flip_y : bool
If True, the returned animation will be flipped vertically.
rotate : int
Degrees of clockwise rotation of the returned animation. Only 90-degree increments are supported.
Returns: Animation

get_max_width

get_max_width(self)

Get the maximum image frame width.

This method is useful for determining texture space requirements: due to the use of anchor_x the actual required playback area may be larger.

Returns: int

get_max_height

get_max_height(self)

Get the maximum image frame height.

This method is useful for determining texture space requirements: due to the use of anchor_y the actual required playback area may be larger.

Returns: int

from_image_sequence

Class Method from_image_sequence(cls, sequence, period, loop=True)
Create an animation from a list of images and a constant framerate.
Parameters:
sequence : list of AbstractImage
Images that make up the animation, in sequence.
period : float
Number of seconds to display each image.
loop : bool
If True, the animation will loop continuously.
Returns: Animation